using System.Collections.Generic;
using System.Text;

namespace SQLRunner.uiStatus
{
    /// <summary>
    /// Manage a collection of PropertyStateList so it delegates the new state value to
    /// each instance within the internal collections
    /// </summary>
    public class PropertyStateManager
    {

        #region Private Instances

        private readonly List<PropertyStateList> _groups = new List<PropertyStateList>();

        #endregion

        #region Public Methods

        public void AddGroup(PropertyStateList propertyState)
        {
            if ( _groups.IndexOf(propertyState) == -1 )
            {
                _groups.Add(propertyState);
            }
        }

        public void UpdateStatus(State state)
        {
            foreach (PropertyStateList _group in _groups)
            {
                _group.UpdateProperty(state);
            }
        }

        public override string ToString()
        {
            StringBuilder strb = new StringBuilder();
            strb.AppendLine("PropertyStateManager");
            foreach (PropertyStateList group in _groups)
            {
                strb.AppendLine(group.ToString());
            }
            return strb.ToString();
        }

        #endregion


    }
}